package com.action.blog;

import java.util.*;

import com.db.blog.*;
import com.opensymphony.xwork2.ActionContext;

public class MainAction {

	private BlogDAO blog;
	private String idtype;
	BlogVO vo = new BlogVO();
	List<BlogListVO> list;

	private int jsppage;
	private int ono;
	private int jsptype;

	public BlogDAO getBlog() {
		return blog;
	}

	public void setBlog(BlogDAO blog) {
		this.blog = blog;
	}

	public int getJsptype() {
		return jsptype;
	}

	public void setJsptype(int jsptype) {
		this.jsptype = jsptype;
	}

	public int getOno() {
		return ono;
	}

	public void setOno(int ono) {
		this.ono = ono;
	}

	public int getJsppage() {
		return jsppage;
	}

	public void setJsppage(int jsppage) {
		this.jsppage = jsppage;
	}

	public void setIdtype(String idtype) {
		this.idtype = idtype;
	}

	public BlogVO getVo() {
		return vo;
	}

	public List<BlogListVO> getList() {
		return list;
	}

	public String execute() throws Exception {

		Map session = ActionContext.getContext().getSession();
		session.put("idtype", idtype);

		if ((!session.get("login").toString().equals(idtype))
				|| session.get("login") == null) {
			int count = 0;
			if (blog.hitSelect(idtype) != 0) {
				count = blog.hitCount(idtype) + 1;
			} else {
				blog.hitInsert(idtype);
			}
			blog.hitUpdate(count);
		}

		Map map = new HashMap();
		map.put("b_id", idtype);

		blog.blogmainInfo(map);

		vo.setId((String) map.get("b_id"));
		vo.setRname((String) map.get("b_rname"));
		vo.setRintro((String) map.get("b_rintro"));
		vo.setRtitle((String) map.get("b_rtitle"));
		vo.setRnickname((String) map.get("b_rnickname"));
		vo.setLove((Integer) map.get("b_love"));
		vo.setGuesthit((Integer) map.get("b_guesthit"));
		vo.setLikeRadio((Integer) map.get("b_likeRadio"));
		System.out.println("1)" + idtype);

		list = blog.BmBoardList(idtype);
		return "success";
	}

}
